package com.nettyrpc.test.server;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(value = 1)
public class AspectHandler {


    @Around("execution(* com.nettyrpc.test.server.HelloServiceImpl.*(..))")
    public Object someServiceAspect(ProceedingJoinPoint pjp) throws Throwable {
        Class<?> targetClass = pjp.getTarget().getClass();
        String methodName = pjp.getSignature().getName();
        System.out.println(targetClass.getName() + "." + methodName + "()");
        System.out.println("[before]");
        Object proceed = pjp.proceed();
        System.out.println("[after]");
        return proceed;
    }
}
